package edu.jd.movieplatform.user.info.Impl;

import edu.jd.movieplatform.security.user.UserDto;
import edu.jd.movieplatform.user.info.UserInfo;
import edu.jd.movieplatform.user.info.UserInfoDto;
import edu.jd.movieplatform.user.info.UserInfoService;
import edu.jd.movieplatform.user.info.dao.UserInfoDao;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import javax.annotation.Resource;
import java.util.List;

@Service
@Transactional
public class UserInfoServiceImpl implements UserInfoService {

    @Resource
    private UserInfoDao userInfoDao;

    @Override
    public UserInfo getUserInfo(String username) {
        return userInfoDao.getUserInfoByUsername(username);
    }

    @Override
    public void modifyInfo(UserInfoDto userInfoDto){
        userInfoDao.updateInfo(userInfoDto);
    }

    @Override
    public boolean checkPassword(String username, String password){
        String oldPassword = userInfoDao.checkPassword(username);
        return oldPassword.equals(password);
    }

    @Override
    public void modifyPassword(String username, String newpassword){
        userInfoDao.updatePassword(username, newpassword);
    }
}
